package VN.EDU.IMIC.DEVELOPER.TRANTHITHANHNGA.OOP.tinhtoan;

public class ModelCal {

	public boolean checkA(Caletity Opt) {
		if (String.valueOf(Opt.getA()).equals("")) {
			return false;
		} else {
			return true;
		}
	}

	public boolean checkB(Caletity Opt) {
		if (String.valueOf(Opt.getB()).equals("")) {
			return false;
		} else {
			return true;
		}
	}

	public boolean checkOpt(Caletity Opt) {
		if (String.valueOf(Opt.getOperate()).equals("")) {
			return false;
		} else {
			return true;
		}
	}

	public double yieldAnswer(Caletity Opt) {
		switch (Opt.getOperate()) {
		case 1:
			return Opt.getA() + Opt.getB();
		case 2:
			return Opt.getA() - Opt.getB();
		case 3:
			return Opt.getA() * Opt.getB();
		case 4: {
			if (Opt.getA() != 0 && Opt.getB() == 0) {
				return Double.valueOf("Cannot devide by zero");
			} else if (Opt.getA() == 0 && Opt.getB() == 0) 
				{return Double.valueOf("Result of function is underfined");}
		}
		}return Math.round(Opt.getA() / Opt.getB());
	}
}

